package com.tudouji.project.flow.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.weixin4j.WeixinException;
import org.weixin4j.spring.WeixinTemplate;

import javax.annotation.PostConstruct;

/**
 * @author xiaxl
 * @version v1.0
 * @ClassName AccessTokenService
 * @Descrption
 * @date 2022/4/12 14:41
 */
@Service("accessTokenService")
public class AccessTokenService {

    @Autowired
    private WeixinTemplate tem;

    private static WeixinTemplate weixinTemplate;

    @PostConstruct
    public void init() {
        weixinTemplate = this.tem;
    }

    public String getToken(){
        String access_token =null;
        try {
            access_token=weixinTemplate.getToken().getAccess_token();
        } catch (WeixinException e) {
            e.printStackTrace();
        }
        return access_token;
    }
}
